package util1;
import com.iflytek.cloud.speech.Setting;
import com.iflytek.cloud.speech.SpeechUtility;
import com.iflytek.util.Version;
import com.iflytek.view.IatSpeechView_By_me;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MeTest_IatSpeechView extends JFrame implements ActionListener {

    String words;
    private JPanel mMainJpanel;
    private JPanel mContentPanel;
    private static JFrame mJframe;
    private JButton jbtnRecognize;
    private JButton jbtnGrammar;
    private JButton jbtnSynthesize;

    private static final long serialVersionUID = 1L;
    public MeTest_IatSpeechView(String words) {
        setTitle("中国银行宾阳分行机器人语音聊天室");
        this.words=words;
        // 初始化
        StringBuffer param = new StringBuffer();
        param.append( "appid=" + Version.getAppid() );
        SpeechUtility.createUtility( param.toString() );
        Setting.setShowLog(false);
        this.setIconImage(Toolkit.getDefaultToolkit().createImage("res/bank_of_china.png"));
        // 设置界面大小，背景图片
        ImageIcon background = new ImageIcon("res/index_bg.png");
        JLabel label = new JLabel(background);
        label.setBounds(0, 0, background.getIconWidth(),
                background.getIconHeight());
        getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
        int frameWidth = background.getIconWidth();
        int frameHeight = background.getIconHeight();

        setSize(frameWidth, frameHeight);//框体的宽高与背景颜色宽高一样
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mContentPanel = new JPanel(new BorderLayout());
        mContentPanel.setOpaque(false);
        //内容面板里放入主面板

        setLocationRelativeTo(null);
        setContentPane(mContentPanel);
       mContentPanel.add(new IatSpeechView_By_me());
        setVisible(true);

    }
    public JPanel getMainJpanel() {
        return mMainJpanel;
    }

    public JPanel getContePanel() {
        return mContentPanel;
    }
    public JButton createImageButton(ImageIcon img) {
        JButton button = new JButton("");
        button.setIcon(img);
        button.setSize(img.getIconWidth(), img.getIconHeight());
        button.setBackground(null);

        button.setBorder(null);
        button.setContentAreaFilled(false);
        button.setFocusPainted(false);

        return button;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jbtnSynthesize) {
//            mContentPanel.remove(mMainJpanel);

//            mContentPanel.revalidate();
//            mContentPanel.repaint();
        }
    }

    public static void main(String[] args) {
        new MeTest_IatSpeechView("");
    }
}
